package wu.example.orderservernacos.controller;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import wu.example.serviceapi.service.UserService;

/**
 * @author benjamin_5
 * @Description
 * @date 2022/11/19
 */
@RestController
public class OrderController {

    @DubboReference
    private UserService userService;
    @Value("${user.age}")
    private Integer userAge;
    @Value("${user.name}")
    private String userName;


    @Value("${server.port}")
    private Integer port;

    @Value("${spring.application.name}")
    private String serverName;

    @GetMapping("test")
    public String test(){
        return "调用服务" + serverName + "，端口："+port;
    }

    @GetMapping("createOrder")
    public String createOrder(Integer id){
        String userName = userService.getUserById(id);
        return userName + " createOrder success";
    }

    @GetMapping("getUser")
    public String getUser(){
        return "用户信息为：name="+userName+",age="+userAge;
    }
}

